package com.bp.project.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bp.common.annotation.Log;
import com.bp.common.core.controller.BaseController;
import com.bp.common.core.domain.AjaxResult;
import com.bp.common.enums.EnumBusinessType;
import com.bp.project.domain.BizStage;
import com.bp.project.service.IBizStageService;
import com.bp.common.utils.poi.ExcelUtil;
import com.bp.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 项目工程步骤Controller
 * 
 * @author shaominjie
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/project/stage")
public class BizStageController extends BaseController {
    @Resource
    private IBizStageService bizStageService;

    /**
     * 查询项目工程步骤列表
     */
    @PreAuthorize("@ss.hasPermi('project:stage:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStage bizStage) {
        startPage();
        List<BizStage> list = bizStageService.selectList(bizStage);
        return getDataTable(list);
    }

    /**
     * 导出项目工程步骤列表
     */
    @PreAuthorize("@ss.hasPermi('project:stage:export')")
    @Log(title = "项目工程步骤", businessType = EnumBusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizStage bizStage) {
        List<BizStage> list = bizStageService.selectList(bizStage);
        ExcelUtil<BizStage> util = new ExcelUtil<BizStage>(BizStage.class);
        return util.exportExcel(list, "stage");
    }

    /**
     * 获取项目工程步骤详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:stage:query')")
    @GetMapping(value = "/{stageId}")
    public AjaxResult getInfo(@PathVariable("stageId") Long stageId) {
        return AjaxResult.success(bizStageService.selectById(stageId));
    }

    /**
     * 新增项目工程步骤
     */
    @PreAuthorize("@ss.hasPermi('project:stage:add')")
    @Log(title = "项目工程步骤", businessType = EnumBusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStage bizStage)
    {
        return toAjax(bizStageService.insert(bizStage));
    }

    /**
     * 修改项目工程步骤
     */
    @PreAuthorize("@ss.hasPermi('project:stage:edit')")
    @Log(title = "项目工程步骤", businessType = EnumBusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStage bizStage) {
        return toAjax(bizStageService.update(bizStage));
    }

    /**
     * 删除项目工程步骤
     */
    @PreAuthorize("@ss.hasPermi('project:stage:remove')")
    @Log(title = "项目工程步骤", businessType = EnumBusinessType.DELETE)
	@DeleteMapping("/{stageIds}")
    public AjaxResult remove(@PathVariable Long[] stageIds) {
        return toAjax(bizStageService.deleteByIds(stageIds));
    }
}
